<template>
  <div class="router">
    <p @click="getDescribe('地址传输必须写路由形式参数')">子路由1 传递参数</p>
    <p fontSize="80px">
            {{ msg }}
      </p>
      <router-link to="/MyRouter/MySubRouter/11111">MySubRouter子路由 地址栏直接写传参</router-link>
      <router-view></router-view>
      <p @click="getDescribe2('地址隐藏传参不用写 路由形式参数')">子路由2 地址隐藏传递参数</p>
    </div>
</template>

<script>
export default {
  name: 'MyRouter',
  data () {
    return {
      msg: '路由基本使用'
    }
  },
  methods: {

    getDescribe (id) {
      this.$router.push({
        path: `/MyRouter/MySubRouter/${id}`
      })
    },
    getDescribe2 (id) {
      this.$router.push({
        name: 'MySubRouter2',
        params: {id: id}
      })
    }
  },
  mounted () {
    console.log(this.$route.params.id)
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
